import { stringify } from 'qs';
import request from '@/utils/request';

//  待我审批列表
export async function getWaitApprovallist(params) {
    return request('/api/oa/v1/workflow/myapprove/getmytoapprove', {
        method: 'POST',
        data: params
    });
}
// 同意
export async function fetAgree(params) {
    return request('/api/oa/v1/workflow/myapprove/agreemyapprove', {
        method: 'POST',
        data: params
    });
}
// 拒绝
export async function fetrefuse(params) {
    return request(`/api/oa/v1/workflow/myapprove/rejectapprove?${stringify(params)}`, {
        method: 'POST'
    });
}
// 退回
export async function fetreturn(params) {
    return request(`/api/oa/v1/workflow/myapprove/fallbackapprove?${stringify(params)}`, {
        method: 'POST'
    });
}
// 字典
export async function fetchtype(params) {
    return request('/api/dict/v1/getList', {
        method: 'POST',
        data: params
    });
}
// 申请类型
export async function fetchtypedata(params) {
    return request('/api/oa/v1/workflow/template/processtypelist', {
        method: 'POST',
        data: params
    });
}
//  经我审批列表
export async function getMyapprovallist(params) {
    return request('/api/oa/v1/workflow/passmeprocess/getpassmeprocesslist', {
        method: 'POST',
        data: params
    });
}
//  待我阅读列表
export async function getMyreadlist(params) {
    return request('/api/oa/v1/workflow/reading/getlist', {
        method: 'POST',
        data: params
    });
}
//  审批详情
export async function fetchDetail(params) {
    return request(
        `/api/oa/v1/workflow/myprocess/getmyprocessdetail?applicationNo=${
            params.applicationNo
        }&formDeploymentId=${params.formDeploymentId || ''}`,
        {
            method: 'POST'
        }
    );
}

export async function fetchProcess(params) {
    return request(`/api/oa/v1/workflow/myprocess/getMyProcessJson?applicationNo=${params}`, {
        method: 'POST'
    });
}

// 更改阅读状态
export async function fetchStatusChange(params) {
    return request(
        `/api/oa/v1/workflow/reading/updatereadingstatus?id=${params.id}&readingStatus=${params.readingStatus}`,
        {
            method: 'POST'
        }
    );
}

// 获取流程代理设置列表
export async function listTemplateAndAgent(parmas) {
    return request('/api/oa/v1/workflow/proxy/listtemplateandagent', {
        method: 'POST',
        data: parmas
    });
}
